/*
 * 微信公众平台(JAVA) SDK
 *
 * Copyright (c) 2014, Ansitech Network Technology Co.,Ltd All rights reserved.
 *
 * http://www.weixin4j.org/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.cl.unipay4j.wx;

import com.cl.unipay4j.core.Configuration;
import com.cl.unipay4j.core.util.StrUtil;
import com.cl.unipay4j.wx.sdk.WXPayConstants;
import lombok.extern.slf4j.Slf4j;

/**
 * 微信支付配置文件
 *
 *
 * @author Small
 * @since 0.0.1
 */
@Slf4j
public class WxConfiguration {
    private static Configuration configuration = Configuration.getInstance();

    /**
     * 获取开发者第三方用户唯一凭证
     *
     * @return 第三方用户唯一凭证
     */
    public static String getAppid() {
        return configuration.getProperty("cl.unipay4j.wx.config.appid");
    }


    /**
     * 获取 小程序appid
     *
     * @return 小程序appid
     */
    public static String getAppletAppid() {
        return configuration.getProperty("cl.unipay4j.wx.config.appletAppid");
    }


    /**
     * 获取 APP appid
     *
     * @return APP appid
     */
    public static String getAppAppId() {
        return configuration.getProperty("cl.unipay4j.wx.config.appAppId");
    }


    /**
     * 获取  商户号
     *
     * @return 商户号
     */
    public static String getMchid() {
        return configuration.getProperty("cl.unipay4j.wx.config.mchid");
    }

    /**
     * 获取  商户号对应的key
     *
     * @return 商户号对应的key
     */
    public static String getKey() {
        return configuration.getProperty("cl.unipay4j.wx.config.key");
    }

    /**
     * 获取 签名类型
     *
     * <p>默认使用HMACSHA256加密</p>
     * @return 签名类型
     */
    public static String getSignType() {
        String signType = configuration.getProperty("cl.unipay4j.wx.config.signType");
        return StrUtil.isNotEmpty(signType) ? signType : WXPayConstants.MD5;
    }


    /**
     * 获取 回调地址
     *
     * @return 回调地址
     */
    public static String getNotifyUrl() {
        return configuration.getProperty("cl.unipay4j.wx.config.notifyUrl");
    }


    /**
     * 获取 是否主动上报
     *
     * @return 是否主动上报
     */
    public static boolean getAutoReport() {
        String autoReport = configuration.getProperty("cl.unipay4j.wx.config.autoReport");
        return Boolean.valueOf(autoReport == null ? "false" : autoReport);
    }

    /**
     * 获取 证书存放路径
     *
     * @return 是否主动上报
     */
    public static String getCertPath() {
        String certPath = configuration.getProperty("cl.unipay4j.wx.config.certPath");
        return certPath;
    }

}
